setInterval(function () {
    var myDate = new Date;
    var year = myDate.getFullYear(); //获取当前年
    var mon = myDate.getMonth() + 1; //获取当前月
    var date = myDate.getDate(); //获取当前日
    var h = myDate.getHours(); //获取当前小时数(0-23)
    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
    var s = myDate.getSeconds(); //获取当前秒
    var week = myDate.getDay();
    var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
    var time = year + "-" + mon + "-" + date + " " + weeks[week] + "   " + (h < 10 ? '0' : '') + h + ":" + (m < 10 ? '0' : '') + m + ":" + (s < 10 ? '0' : '') + s;
    $("#system-time").html(time);
}, 1000);

var takeNumber;
var windowsId;
    <!--ajax与servlet的连接-->
//开始服务或登陆失败
    $('.login').on("click",function(){

        if ($(".switch input").is(":checked")){
            var business=1;
        }else {
            var business=2;
        }
        var account=document.getElementById("id-number").value;
        var password=document.getElementById("password").value;
        //获取windowsid
        windowsId=$("#windowsId").val();
        var url="/caller/login";
        $.getJSON(url,{account:account,password:password,windowsId:windowsId,business:business},
            function(data){
                if(data==1){
                    $("#verify").show();
                    $(".login-form").hide();
                    $('.code').on("click",function(){
                        var code=$("#verify input").val();
                        $.getJSON("/caller/verifycode",{windowsId:windowsId,code:code},
                            function(data){
                                if(data){
                                    //跳转叫号
                                    $(".login-form").hide();
                                    $(".call-terminal").show();
                                    $("#verify").hide();
                                }else{
                                    alert("验证码错误");
                                }
                            });
                    });


                }else{
                    alert("账号密码错误");
                }
            });
    });
//办理成功  3

    $('#service-success').on("click",function(){
        var url="/caller/success/"+takeNumber;
        $.getJSON(url,{windowsId:windowsId},
            function (data) {

            }
        )
    });
//下个号码  1
    $('#next-number').on("click",function(){
        var url="/caller/next";
        $.getJSON(url,{requestType:1,windowsId:windowsId},
            function (data) {
                number=data;
                $('#current-number').text(data);
                takeNumber=data;
            }
        )
    });
//重复叫号  2
    $('#repeat-call').click(function(){
        var url="/caller/repeatcall";
        $.getJSON(url,{number:takeNumber,windowsId:windowsId},
            function (data) {

            }
        )
    });

//办理失败  4
    $('#service-fail').click(function(){
        var url="CallerServiceServlet";
        $.getJSON(url,{requestType:4},
            function (data) {

            }
        )
    });


function transfer(previous, current, target, timeout, instantPass, callback) {
    previous.hide();
    current.show();
    $(".return-second").html(timeout);
    var returnInterval = setInterval(function () {
        timeout--;
        $(".return-second").html(timeout);
        if (timeout == 0) {
            clearInterval(returnInterval);
            previous.show();
            current.hide();
            callback(false);
            return;
        }
    }, 1000);
    if (instantPass == true) {
        $(document).on("click", ".check-pass", function (e) {
            e.preventDefault();
            current.hide();
            target.show();
            $(document).off("click", ".check-pass");
            $(document).off("click", ".back");
            clearInterval(returnInterval);
            callback(true);
            return;
        });
    }
    $(document).on("click", ".back", function (e) {
        e.preventDefault();
        current.hide();
        previous.show();
        $(document).off("click", ".check-pass");
        $(document).off("click", ".back");
        clearInterval(returnInterval);
        callback(false);
        return;
    });
}

var loginForm = $(".login-form");
var callTerminal = $(".call-terminal")
var idScan = $(".id-scan");

(function stopService() {
    $(document).on("click", "#service-stop", function (e) {
        $("#service-stop").hide();
        transfer(callTerminal, idScan, loginForm, 30, true, function (result) {
            if (!result) {
                $("#service-stop").show();
            }
        });
    });
})();

(function startService() {
    $(document).on("click", "#card-login", function (e) {
        transfer(loginForm, idScan, callTerminal, 30, true, function (result) {
            if (result) {
                $("#service-stop").show();
            }
        });
    });
})();

var nextNumber = $("#next-number");
var repeatCall = $("#repeat-call");
var serviceSuccess = $("#service-success");
var serviceFail = $("#service-fail");
var stopService = $("#service-stop");

(function CallerLogic() {
    $(document).on("click", "#next-number", function (e) {
        nextNumber.attr("disabled", true);
        repeatCall.attr("disabled", false);
        serviceSuccess.attr("disabled", false);
        serviceFail.attr("disabled", false);
        stopService.attr("disabled", true);
        if ($("#call-status").text() == "等待叫号") {
            $("#call-status").text("号");
        }
    });
    $(document).on("click", "#repeat-call", function (e) {
        nextNumber.attr("disabled", true);
        repeatCall.attr("disabled", false);
        serviceSuccess.attr("disabled", false);
        serviceFail.attr("disabled", false);
        stopService.attr("disabled", true);
    });
    $(document).on("click", "#service-success", function (e) {
        nextNumber.attr("disabled", false);
        repeatCall.attr("disabled", true);
        serviceSuccess.attr("disabled", true);
        serviceFail.attr("disabled", true);
        stopService.attr("disabled", false);
        $("#current-number").text("");
        $("#call-status").text("等待叫号");
    });
    $(document).on("click", "#service-fail", function (e) {
        nextNumber.attr("disabled", false);
        repeatCall.attr("disabled", true);
        serviceSuccess.attr("disabled", true);
        serviceFail.attr("disabled", true);
        stopService.attr("disabled", false);
        $("#current-number").text("");
        $("#call-status").text("等待叫号");
    });
})();